﻿using Orleans;
using Pay.Container;
using Pay.Dal;
using Pay.Model.Interfaces;
using Pay.Model.Model;
using Pay.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.ServiceImplement
{
   public  class ApplyServiceImplement:Grain,IApplyService
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<long> Add(ApplyInfo model)
        {
            var instance = LocManager.Resolve<IApplyDal>();
            return await instance.Add(model);
        }
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="searchWord"></param>
        /// <param name="MId"></param>
        /// <param name="timeBegin"></param>
        /// <param name="timeEnd"></param>
        /// <param name="offset"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public async Task<IPagedOutput<ApplyInfo>> GetPage(long? MId, DateTime? timeBegin = null, DateTime? timeEnd = null, int offset = 10, int rows = 1)
        {
            var instance = LocManager.Resolve<IApplyDal>();
            return await instance.GetPage(MId, timeBegin, timeEnd, offset, rows);
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<bool> Update(ApplyInfo model)
        {
            var instance = LocManager.Resolve<IApplyDal>();
            return await instance.Update(model);
        }

        /// <summary>
        /// 更加商户ID获取商户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<MerchantInfo> GetByMerchantId(long id)
        {

            var instance = LocManager.Resolve<IApplyDal>();
            return await instance.GetByMerchantId(id);
        }

        public async Task<ApplyInfo> GetById(long id)
        {
            var instance = LocManager.Resolve<IApplyDal>();
            return await instance.GetById(id);
        }
    }
}
